#include<bits/stdc++.h>
using namespace std;
int T,n,a[100010],num[100010],vis[100010],ans;
int main(){
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    cin>>T;
    while(T--){
        ans=0;
        cin>>n;
        for(int i=1;i<=n;i++){
            cin>>a[i];
            num[a[i]]=1;
            vis[a[i]]=0;
        }
        sort(a,a+n+1);
        for(int i=2;i<=n;i++){
            if(a[i]==a[i-1]) num[a[i]]++;
        }
        for(int i=1;i<=n;i++){
            if(vis[a[i]]==0){
                ans+=num[a[i]]/2*a[i];
                vis[a[i]]=1;
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}
